﻿Imports System.Data
Imports System.Data.SqlClient
Imports CondorTravel.BE
Imports CondorTravelUTIL.DL



Public Class PaisDALC


    Public Function ListarPais() As List(Of PaisBE)

        Dim sqlPaisListar As String
        Dim listPaisBE As List(Of PaisBE) = Nothing
        Dim objPaisBE As PaisBE = Nothing
        Dim ds As DataSet
        Dim dt As DataTable

        Try

            sqlPaisListar = "SP_PaisList"

            Dim oDatos As New AccesoDatos()
            Dim bExito As Boolean
            Dim sMensaje As String = String.Empty
            Dim i As Integer = 0

            ds = oDatos.DevuelveDataSet(sqlPaisListar, bExito, sMensaje, Nothing)
            dt = ds.Tables(0)


            listPaisBE = New List(Of PaisBE)()

            If dt.Rows.Count > 0 Then

                While i < dt.Rows.Count
                    objPaisBE = New PaisBE()
                    objPaisBE.Codigo = CType(dt.Rows(i).ItemArray(0).ToString, Integer)
                    objPaisBE.Descripcion = dt.Rows(i).ItemArray(1).ToString
                    i = i + 1

                    listPaisBE.Add(objPaisBE)
                End While
            End If

        Catch ex As Exception
            MsgBox(ex.Message, vbCritical, "Error del sistema")
            Return Nothing
            Exit Function
        End Try

        Return listPaisBE

    End Function


End Class
